package com.wcy.serviceimpl;

import com.wcy.entity.City;
import com.wcy.entity.User;
import com.wcy.dao.UserMapper;
import com.wcy.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @since 2021-04-30
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    UserMapper userMapper;

    /**
     * 用户列表
     * @param uphones
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<User> queryAll(String uphones, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> userList = userMapper.queryAll(uphones);
        return new PageInfo<>(userList);
    }

    /**
     * 密码修改
     * @param password
     * @param id
     * @return
     */
    @Override
    public int setPassword(String password,String id) {
        return userMapper.setPassword(password,id);
    }

    /**
     * 用户增加
     * @param
     * @param
     * @return
     */

    @Override
    public int add(User user) {
        return userMapper.add(user);
    }

    @Override
    public List<City> queryCity(int pid) {
        return userMapper.queryCity(pid);
    }

    @Override
    public int delUserById(String id) {
        return userMapper.delUserById(id);
    }

    @Override
    public int delByUid(int uid) {
        return userMapper.delByUid(uid);
    }

    @Override
    public void addRid(int uid,int j) {
        userMapper.addRid(uid,j);
    }

    @Override
    public List<User> selectById(int id) {
        return userMapper.selectById(id);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }
}
